<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <img src="ac1.jpg" />
</body>
<script>
    var arr = ['ac1.jpg', 'ac2.jpg', 'ac3.jpeg', 'ac4.jpg'];
    var i = 1;
    var img = document.querySelector('img');
    setInterval(function() {
        if (i == 4) {
            i = 0;
        }
        img.src = arr[i];
        i++;
    }, 2000)
</script>

</html>